<?php 

// 添加用户 
function addUserInfo($userObj){//第一个参数是服务器地址   第四个参数是数据库名
  $mysql = new mysqli(SAE_MYSQL_HOST_M.":".SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS,SAE_MYSQL_DB);

  // 清除乱码
  $mysql->query("set names utf8");

// 	昵称
	$nickname = $userObj->nickname;
	// 国家
	$country = $userObj->country;
	// 省份
	$province = $userObj->province;
	// 城市
	$city = $userObj->city;
	// 头像信息
	$headimgurl = $userObj->headimgurl;
	// 性别
	$sexNum = $userObj->sex;
	if ($sexNum == 1) {
		$sex = "男";
	}elseif ($sexNum == 2) {
		$sex = "女";
	}else{
		$sex = "未知";
	}
	$sql = "INSERT INTO test (openid,nickname) VALUES ('{$openid}','{$nickname}')";
	$result = $mysql->query($sql);
	
	$mysql->close();
}



// 更新分数
function  updateScore($openid,$score){
  // 链接数据库
  $mysql = new mysqli(SAE_MYSQL_HOST_M.":".SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS,SAE_MYSQL_DB);
//清除乱码
  $mysql->query("set names utf8");

// sql语句
$sql = "UPDATE shuqiansql SET score = '$score' WHERE openid = '$openid'";
$result = $mysql->query($sql);
  $mysql->close();
}


 ?>